import "../../justfile"

dag:
  #!/usr/bin/env bash
  pushd {{ROOT}}
  cargo run -p cu29-runtime --bin cu29-rendercfg -- --open examples/cu_rp_balancebot/copperconfig.ron 
  popd

balancebot-dump-text-logs:
	#!/usr/bin/env bash
	set -euo pipefail
	cargo run --bin balancebot-logreader -- logs/balance.copper extract-text-log ../../target/debug/cu29_log_index/strings.bin

balancebot-fsck:
	#!/usr/bin/env bash
	set -euo pipefail
	cargo run --bin balancebot-logreader -- logs/balance.copper fsck

balancebot-set-pwm-permissions:
	#!/usr/bin/env bash
	set -euo pipefail
	for pwm in /sys/class/pwm/pwmchip0/pwm*/; do
		chmod 0660 "${pwm}enable"
		chmod 0660 "${pwm}duty_cycle"
		chmod 0660 "${pwm}period"
		chmod 0660 "${pwm}polarity"
		chown root:wheel "${pwm}enable"
		chown root:wheel "${pwm}duty_cycle"
		chown root:wheel "${pwm}period"
		chown root:wheel "${pwm}polarity"
	done
	chmod 0660 /sys/class/pwm/pwmchip0/unexport
	chown root:wheel /sys/class/pwm/pwmchip0/unexport
